function Idverify() {
    this.init();
}
Idverify.prototype.init = function() {
	var me = this;
	var template = __inline("./idverify.tmpl");
    var content = template({
    	current:me._current,
    	count:me._count
    });
    $(document.body).append(content);
};
Idverify.prototype.show = function() {
    var me = this;
	$('#idverify').modalBox({
        keyClose:true,
        overlay:true,
        bodyClose:false
    });
    $('.close_btn').click(function () {
        $('#idverify').modalBox('close');
    });
    $('#id_card_name').bind('change', function() {
        me.checkForm();
    });
    $('#id_card').bind('change', function() {
        me.checkForm();
    });
    $('#re_id_card').bind('change', function() {
        me.checkForm();
    });
};
Idverify.prototype.hide = function() {
    $('#idverify').modalBox('close');
};
Idverify.prototype.setError = function(error_msg) {
    $('#idverify .info').text(error_msg).addClass('info-error');
//    $('#idverify .info').css('color','#F90');
};
Idverify.prototype.resetError = function() {
    $('#idverify .info').removeClass('info-error').
        text('为保障您的资金安全，请进行实名认证。3次验证失败后将冻结账户。如果实名认证不成功，请将您的身份证正面和反面复印并发邮件到service@zhenrongbao.com，走人工认证环节。');
//    $('#idverify .info').css('color','#000');
};
Idverify.prototype.checkForm = function(){
    var me = this;
    var id_card = $('#id_card').val();
    var re_id_card = $('#re_id_card').val();
    var id_card_name = $('#id_card_name').val();
    if(!id_card_name) {
        me.setError('请输入姓名。');
        return;
    }
    if(!id_card) {
        me.setError('请输入身份证号码。');
        return;
    }
    if(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(id_card) == false) {
        me.setError('请输入正确的身份证号');
        return;
    }
    if(!re_id_card) {
        me.setError('请再次确认身份证号。');
        return;
    }
    if(re_id_card != id_card) {
        me.setError('2次输入的身份证号不一致，请确认。');
        return;
    }
    me.resetError();
    return {'id_card_name':id_card_name,'id_card':id_card};
}
module.exports = Idverify;